package cn.iocoder.yudao.module.form.controller;

import cn.iocoder.yudao.module.form.dataobject.CugbEquipment;
import cn.iocoder.yudao.module.form.service.ICugbEquipmentService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 设备采购Controller
 *
 * @author cugb
 * @date 2022-08-26
 */
@Api(tags = "CUGB设备")
@RestController
@RequestMapping("/admin-api/pollution/equipment")
public class CugbEquipmentController
{
    @Autowired
    private ICugbEquipmentService cugbEquipmentService;

    /**
     * 查询设备采购列表
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:list')")
    @GetMapping("/list")
    @ApiOperation(value = "列表查询CUGB设备", notes = "列表查询CUGB设备")
    public CommonResult<List<CugbEquipment>> list(CugbEquipment cugbEquipment)
    {
//        startPage();
        List<CugbEquipment> list = cugbEquipmentService.selectCugbEquipmentList(cugbEquipment);
        return success(list);
    }

    /**
     * 导出设备采购列表
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:export')")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, CugbEquipment cugbEquipment)
//    {
//        List<CugbEquipment> list = cugbEquipmentService.selectCugbEquipmentList(cugbEquipment);
//        ExcelUtil<CugbEquipment> util = new ExcelUtil<CugbEquipment>(CugbEquipment.class);
//        util.exportExcel(response, list, "设备采购数据");
//    }

    /**
     * 获取设备采购详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:query')")
    @GetMapping(value = "/{equId}")
    @ApiOperation(value = "依据id查询CUGB设备", notes = "依据id查询CUGB设备")
    public CommonResult<CugbEquipment> getInfo(@PathVariable("equId") Long equId)
    {
        return success(cugbEquipmentService.selectCugbEquipmentByEquId(equId));
    }

    /**
     * 新增设备采购
     * @return
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:add')")
    @PostMapping
    @ApiOperation(value = "新增CUGB设备", notes = "新增CUGB设备")
    public CommonResult<Integer> add(@RequestBody CugbEquipment cugbEquipment)
    {
        return success(cugbEquipmentService.insertCugbEquipment(cugbEquipment));
    }

    /**
     * 修改设备采购
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:edit')")
    @PutMapping
    @ApiOperation(value = "修改CUGB设备", notes = "修改CUGB设备")
    public CommonResult<Integer> edit(@RequestBody CugbEquipment cugbEquipment)
    {
        return success(cugbEquipmentService.updateCugbEquipment(cugbEquipment));
    }

    /**
     * 删除设备采购
     */
//    @PreAuthorize("@ss.hasPermi('system:equipment:remove')")
	@DeleteMapping("/{equIds}")
    @ApiOperation(value = "依据id删除CUGB设备", notes = "依据id删除CUGB设备")
    public CommonResult<Integer> remove(@PathVariable Long[] equIds)
    {
        return success(cugbEquipmentService.deleteCugbEquipmentByEquIds(equIds));
    }
}
